<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018\5\17 0017
 * Time: 18:20
 */

namespace App\Services;



use App\Models\Permission;

class RoleService
{
    public static function rolePremission($role,$permissions){
        $permission_ids = $role->permissions->pluck('id');
        $new_permission_ids = Permission::find($permissions)->pluck('id');

        $addIds = $new_permission_ids->diff($permission_ids);
        $delIds = $permission_ids->diff($new_permission_ids);

        $role->permissions()->attach($addIds);
        $role->permissions()->detach($delIds);
    }

}